package com.ruoyi.common.utils;


import com.ruoyi.common.enums.IBaseEnum;

import java.io.Serializable;

/**
 * @ClassName EnumUtil
 * @Description
 * @Author Small
 * @Date 2019/12/10 9:44
 * @Version 1.0
 **/
public class EnumUtil {

    public static <T extends IBaseEnum> T getIEnum(Class<T> targerType, Serializable source) {
        for (T enumObj : targerType.getEnumConstants()) {
            if (source.equals(enumObj.getValue())) {
                return enumObj;
            }
        }
        return null;
    }
}
